# encoding:utf-8
import time

from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.common.by import By


# 八大选择器

class WebDriverFactory:
    __instance = None

    @classmethod
    def get_instance(cls):
        if not cls.__instance:
            cls.__instance = WebDriver()
        return cls.__instance


class BaiduSearchXpathMap:
    TEXT_INPUT_BOX = (By.ID, "kw")


driver = WebDriverFactory.get_instance()
driver.maximize_window()
driver.get("http://www.baidu.com")
# By.ID
# driver.find_element(By.ID, "kw").send_keys("selenium")
# By.NAME
# driver.find_element(By.NAME, "wd").send_keys("Java")
# time.sleep(3)
# By.CLASS_NAME
# driver.find_element(By.CLASS_NAME, "s_ipt").clear()
# By.PARTIAL_LINK_TEXT
# driver.find_element(By.PARTIAL_LINK_TEXT, "hao").click()
time.sleep(3)
# driver.find_element(By.LINK_TEXT, "hao123").click()

# driver.find_element(By.XPATH, '//*[@id="kw"]').send_keys("xpath语法")
# time.sleep(3)

# driver.find_element(By.CSS_SELECTOR, '[name="wd"]').send_keys("-------------")
# time.sleep(3)

driver.find_element(By.TAG_NAME, 'input').send_keys('python')
time.sleep(3)